package com.dq.Service.Impl;

import com.dq.Mapper.StuMapper;
import com.dq.Pojo.Student;
import com.dq.Service.StuService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.poi.ss.formula.functions.Intercept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class
StuServiceImpl implements StuService {
    @Autowired
    private StuMapper stuMapper;

    @Override
    public void addstu(Student student) {
        stuMapper.addstu(student);
    }

    @Override
    public Student findstu(Integer id) {
        return stuMapper.findstu(id);
    }

    @Override
    public void update(Student student) {
        stuMapper.update(student);
    }

    @Override
    public PageInfo<Student> findAll(Integer pageNum, Integer pageSize, String name, String stuno) {
        PageHelper.startPage(pageNum,pageSize);
        List<Student> studentList=stuMapper.findAll(name,stuno);
        PageInfo<Student> pageInfo=new PageInfo<>(studentList);
        return pageInfo;
    }

    @Override
    public void delete(Integer id) {
        stuMapper.delete(id);
    }

    @Override
    public List<Student> findByclassid(Integer classId) {
        return stuMapper.findByclassid(classId);
    }
}
